<template>
	<view class="bg">
		<!-- <image src="../../images/loading.gif" mode="aspectFill" style="width: 400rpx;height: 300rpx;"></image> -->
	</view>
</template>

<script>
	export default {
		data(){
			return {
				
			}
		},
		onLoad() {

				const sUserAgent = window.navigator.userAgent.toLowerCase();
				const bIsDtDreamApp = sUserAgent.indexOf("dtdreamweb") > -1; // 浙里办APP
				const bIsAlipayMini =
				  sUserAgent.indexOf("miniprogram") > -1 &&
				  sUserAgent.indexOf("alipay") > -1;
				if (bIsDtDreamApp) {

				  this.watchApp();
				} else if (bIsAlipayMini) {
				  this.watchApply();
				}	
		},
		methods:{
			logins(){
					const sUserAgent = window.navigator.userAgent.toLowerCase();
					const bIsDtDreamApp = sUserAgent.indexOf("dtdreamweb") > -1; // 浙里办APP
					const bIsAlipayMini =
						sUserAgent.indexOf("miniprogram") > -1 &&
						sUserAgent.indexOf("alipay") > -1;
						if (bIsDtDreamApp) {
							window.location.href = "https://puser.zjzwfw.gov.cn/sso/mobile.do?action=oauth&scope=1&servicecode=llt"	
						} else if (bIsAlipayMini) {
							window.location.href = "https://puser.zjzwfw.gov.cn/sso/alipay.do?action=ssoLogin&servicecode=llt"	
						}
			},
			watchApp() {
			  var that = this;

			  window.addEventListener(
				"pageshow",
				function (event) {
				  if (
					event.persisted || (window.performance && window.performance.navigation.type == 2)  ) {
					ZWJSBridge.close()//这个是浙里办内部的api，调用close()接口关闭通过openLink打开的页面
					  .then((result) => {
						// console.log(result);
					  })
					  .catch((error) => {
						console.log(error);
					  });
				  }
				},
				false
			  );
			  that.logins()
			},
			watchApply() {
				// console.log(2222)
				  var that = this;
				  window.addEventListener(
					"pageshow",
					function (event) {
					  if (event.persisted || (window.performance && (window.performance.navigation.type == 1 ||	window.performance.navigation.type == 0)) ) {
					  } else if (event.persisted ||(window.performance && window.performance.navigation.type == 2) ) {
						my.navigateBack();
					  } else {
						my.navigateBack();//支付宝小程序的api，需在index.html引入，通过此api直接跳回浙里办小程序页面
					  }
					},
					false
				  );
				  that.logins()
				},	
		}
	}
</script>

<style>

</style>
